import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# pandas相关性分析
data = {
    "A": [1, 0, 0, 1, -1, 1, -1],
    "B": [1, 1, 0, 1, 0, 1, -1],
    "C": [0, 1, -1, -1, 0, 0, 1],
    "D": [1, 0, 0, 1, 0, 1, -1],
    "E": [1, 1, -1, 1, 0, 1, -1],
    "F": [-1, 1, -1, 1, 1, 1, -1],
}

df = pd.DataFrame(data)
correlation_matrix = df.corr(method="pearson")
print(correlation_matrix)

correlation_matrix = correlation_matrix.round(4)
print(correlation_matrix)
plt.figure(figsize=(10, 8))
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', linewidths=0.5)
plt.title('Correlation Matrix Heatmap')
plt.show()
